//
//  HttpTool.m
//  Weibo
//
//  Created by Anasue on 9/17/15.
//  Copyright (c) 2015 Anasue. All rights reserved.
//

#import "HttpTool.h"
#import "AFNetworking.h"
#import "AccountTool.h"
#import "Account.h"
@implementation HttpTool

+ (void)get:(NSString *)url params:(NSDictionary *)params success:(void(^)(id))success failure:(void (^)(NSError *))failure
{

    //添加请求管理者
    AFHTTPRequestOperationManager *mgr = [AFHTTPRequestOperationManager manager];

    //发送GET请求
    [mgr GET:url parameters:params success:^(AFHTTPRequestOperation *operation, NSDictionary *resultDict) {
        if (success) {
            success(resultDict);
        }
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}

+ (void)post:(NSString *)url params:(NSDictionary *)params success:(void(^)(id))success failure:(void (^)(NSError *))failure
{
    
    //添加请求管理者
    AFHTTPRequestOperationManager *mgr = [AFHTTPRequestOperationManager manager];
    
    //发送GET请求
    [mgr POST:url parameters:params success:^(AFHTTPRequestOperation *operation, NSDictionary *resultDict) {
        if (success) {
            success(resultDict);
        }
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}

@end
